<?php
	include_once("../include/init.php");
	include_once("admin_init.php");
	$sql = "SELECT * FROM  tk_pinglun t, tk_user u where u.uid=t.uid ";
	$res = mysql_query($sql);
	//分页
	$totalRows= mysql_num_rows($res);
	$pageRows = 4;
	$totalpage= ceil($totalRows / $pageRows);
	$page = isset($_GET['page'])?$_GET['page']:1;
	if($page <= 0 ||$page >$totalpage ||!is_numeric($page)){
		$page = 1;

	}
	$limitStart =$pageRows *($page -1);
	$sql = "select * from tk_pinglun t, tk_user u where u.uid = t.uid order by p_id desc limit {$limitStart},{$pageRows}";
	$res = mysql_query($sql);
	$info = [];
	if(mysql_num_rows($res)>0){
		while($list=mysql_fetch_assoc($res)){
			$info[]=$list;
		}
	}
?>


<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>主体部分</title>
	<base target="_self">
	<link rel="stylesheet" type="text/css" href="skin/css/base.css" />
	<link rel="stylesheet" type="text/css" href="skin/css/main.css" />
</head>
<body leftmargin="8" topmargin='8'>
	<table width="98%" align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px;margin-top:8px;">
	  <tr>
	    <td background="./skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' border="0px"><span><img src='./skin/images/frame/arr3.gif' style='margin-right:10px;'>评论</span></td>
		<td align="right" background="./skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' border="0px"></td>
	  </tr>
	  <tr bgcolor="#FFFFFF">
	    <td colspan="2">
			<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CFCFCF" align="center" style="margin-top:8px">
				<tr align="center" bgcolor="#FBFCE2" height="25">
					<td width="6%">ID</td>
					<td width="10%">用户名</td>
					<td width="28%">评论状态</td>
					<td width="10%">评论内容</td>
					<td width="10%">评论时间</td>
					<td width="10%">操作</td>
				</tr>
	  <!-- data start-->
	  			<?php foreach ($info as $vo){?>
				<tr align='center' bgcolor="#FFFFFF" height="26" align="center" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
					<td nowrap>
						<?=$vo['p_id']?>
					</td>
					<td >
						<?=$vo['user']?>
					</td>
					<td>
								<?php
								if($vo['p_status']==1){
									echo"满意";
								}elseif($vo['p_status']==2){
									echo"一般";
								}elseif($vo['p_status']==0){
									echo"不满意";
								}
								?>
					</td>
					<td>
						<?=$vo['p_content']?>
					</td>
					<td><?=date("Y-m-d H:i:s",$vo['p_time'])?></td>
					<td>
						
						<a href="javascript:deleteAdmin(<?=$vo['p_id']?>)">
						<img src='./skin/images/frame/gtk-del.png' title="删除" alt="删除" onClick="editArc(179);" style='cursor:pointer' border='0' width='16' height='16' />
						</a>
					</td>
				</tr>
				<?php }?>
	  <!-- data end-->
	  <!-- select start-->

	  <!-- select end-->
	  <!-- page start-->
		  <tr align="right" bgcolor="#F9FCEF">
			<td height="36" colspan="10" align="center">
				<div class="pagelistbox">
					<span>共<?php echo $totalpage;?>页/<?php echo $totalRows;?>条记录 </span>
					<span class='indexPage'><a href="?page=1">首页 </a>
					<a class='prevPage' href='?page=<?php echo $page-1?>'>上页</a> 
					</span>
					<?php for($i=1;$i<=$totalpage;$i++):?>
						<?php if($i == $page):?>
							<strong><?php echo $i;?></strong>
							<?php else:?>
							<a href='?page=<?php echo $i;?>'><?php echo $i;?></a>
						<?php endif;?>
					<?php endfor;?>
					<a class='nextPage' href='?page=<?php echo $page+1;?>'>下页</a> 
					<a class='endPage' href='?page=<?php echo $totalpage;?>'>末页</a> 
					</div>
				</td>
		  </tr>
	  <!-- page end-->
	</table>
	<script>
		function deleteAdmin(p_id){
			if(confirm('确认删除？')){
				window.location.href = "comment.php?act=del&id="+p_id;
			}
		}

	</script>
	</body>
</html>